|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.vtp.framework.util.XMLUtilities
public class XMLUtilities
Static utility class that hosts functions that make dealing with xml formatted content easier.
| Constructor Summary | |
|---|---|
XMLUtilities()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
encodeAttribute(java.lang.String toEncode)
Encodes the given string so that it conforms to the XML 1.0 specification for attribute values. |
static java.lang.String |
encodeText(java.lang.String toEncode)
Encodes the given string so that it conforms to the XML 1.0 specification for CDATA and TEXT nodes. |
static javax.xml.parsers.DocumentBuilder |
getDocumentBuilder()
Convenience function to get a DOM document builder object. |
static org.w3c.dom.Element[] |
getElementsOfNodeList(org.w3c.dom.NodeList nodeList)
Returns an array containing the element objects in the provided node list. |
static java.lang.String |
getElementTextData(org.w3c.dom.Element element)
Returns the text content of the provided element as is. |
static java.lang.String |
getElementTextData(org.w3c.dom.Element element,
boolean unindent)
Returns the text content of the provided element. |
static org.w3c.dom.NodeList |
getNamedNodeList(org.w3c.dom.Element parent,
java.lang.String containerTagName)
Retrieves the DOM NodeList contained by the named element
in the given parent element. |
static java.lang.String |
getWrappedTextData(org.w3c.dom.Element parent,
java.lang.String childTagName)
A convenience method that allows the extraction of text data from a named child element of the given parent element. |
static org.w3c.dom.Document |
loadDocument(java.io.File documentFile)
Loads the given file using the default XML DOM implementation. |
static java.lang.String |
unindentTextData(java.lang.String text)
Removes excess indention from the provided text. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public XMLUtilities()
| Method Detail |
|---|
public static java.lang.String encodeAttribute(java.lang.String toEncode)
toEncode - The string to encode
public static java.lang.String encodeText(java.lang.String toEncode)
toEncode - The string to encode
public static org.w3c.dom.NodeList getNamedNodeList(org.w3c.dom.Element parent,
java.lang.String containerTagName)
throws java.lang.Exception
NodeList contained by the named element
in the given parent element.In the above example, a
NodeList containing the two
elements would be returned by passing the parent element and "named-list" into the function parameters.
parent - The parent DOM element that contains the named list.containerTagName - The name of the element that contains the list items.
NodeList containing the list items.
java.lang.Exception - If an exception occurs while traversing the DOM objects.public static org.w3c.dom.Element[] getElementsOfNodeList(org.w3c.dom.NodeList nodeList)
nodeList - The DOM node objects to extract elements from.
public static java.lang.String getWrappedTextData(org.w3c.dom.Element parent,
java.lang.String childTagName)
throws java.lang.Exception
[Text Data]
parent - The parent DOM element.childTagName - The name of the child element.
java.lang.Exception - If an error occurs while traversing the DOM objects.
public static java.lang.String getElementTextData(org.w3c.dom.Element element)
throws java.lang.Exception
element - The element that contains the desired text content.
java.lang.Exception - If an exception occurs during the traversal of the DOM
objects.
public static java.lang.String getElementTextData(org.w3c.dom.Element element,
boolean unindent)
throws java.lang.Exception
element - The element that contains the text content.unindent - Whether or not to unindent the text content.
java.lang.Exception - If an exception occurs during the traversal of the DOM
elements.public static java.lang.String unindentTextData(java.lang.String text)
text - The text to unindent.
public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
throws javax.xml.parsers.ParserConfigurationException
DocumentBuilder instance.
javax.xml.parsers.ParserConfigurationException
public static org.w3c.dom.Document loadDocument(java.io.File documentFile)
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException,
java.io.IOException
documentFile - The file to load.
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||